package ru.pstu.itas.cps.controls;

public abstract class ActiveElement extends ControlElement {

	String id;
	int x;
	int y;
	int value;
	OnChangeListener listener = null;

	public ActiveElement(String id, int x, int y, int value) {
		super();
		this.id = id;
		this.x = x;
		this.y = y;
		this.value = value;
	}

	public String getId() {
		return id;
	}

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		if (this.value != value) {
			this.value = value;
			listener.onChange(id, value);
		}
	}

	public static interface OnChangeListener {
		public abstract void onChange(String controlId, int newValue);
	}

	public void setOnChangeListener(OnChangeListener listener) {
		this.listener = listener;
	}

}
